package com.arajuuri.catinvaders.fileoperations;

import java.awt.Frame;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.net.URL;

public class Images {

    public Images() {
    }

    public Image loadImage(String imgName) {
        Toolkit tk = Toolkit.getDefaultToolkit();
        URL url = this.getClass().getResource("/img/" + imgName);
        Image image = tk.getImage(url);
        MediaTracker tracker = new MediaTracker(new Frame());
        try {
            tracker.addImage(image, 0);
            tracker.waitForID(0);
        } catch (InterruptedException ie) {
        }
        return image;
    }
}
